def insert_sort(arr):
    l = len(arr)
    for i in range(1, l):
        j = i-1
        temp = arr[i]
        while j >= 0 and arr[j] > temp:            
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = temp
    return arr
print(insert_sort([5,5,5,2,3,8,1])) 
